/**
 * @desc //TODO $
 * @param $
 * @return $
 **/
package http

import (
	"encoding/json"
	"errors"
)

type Respone struct {
	Code int
	Data map[string]interface{}
	Msg string
}

func ApiTest(method string, url string, params Params, headers map[string]string)(data map[string]interface{}, err error){
	var resp []byte
	resp, err = Request(method, url, params, nil)
	if err == nil {
		var respone Respone
		err := json.Unmarshal(resp, &respone)
		if err != nil || respone.Code != 200 {
			return nil, errors.New(respone.Msg)
		}

		return respone.Data, err
	}
	return nil, err
}
